package com.ymf.page.controller;

import com.ymf.page.pojo.Description;
import com.ymf.page.pojo.MyMessage;
import com.ymf.page.pojo.Skills;
import com.ymf.page.pojo.data;
import com.ymf.page.service.MyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/My")
@RefreshScope   //刷新配置
public class MyController {
    @Autowired
    private MyService myService;

//    @Value("${test.name}")
//    private String name;

    @GetMapping("all")
    public List<MyMessage> findAll(){
//        System.out.println(name);
        return myService.findAll();
    }
    @GetMapping("desc/{id}")
    public List<Description> desc(@PathVariable int id){
        return myService.findDescription(id);
    }
    @PostMapping("updataAboutMe")
    public int updataAboutMe(@RequestBody MyMessage myMessage){
        return myService.updataAboutMe(myMessage);
    }
    @PostMapping("updatamy_message")
    public int updataMy_message(@RequestBody MyMessage myMessage){
        return myService.updataMy_message(myMessage);
    }
    @GetMapping("findskills")
    public List<Skills> findskills(){
        return myService.findallSkills();
    }
    @GetMapping("deleteskillsbyid/{id}")
    public int deleteSkillsById(@PathVariable int id){
        return myService.deleteSkillsById(id);
    }
    @PostMapping("insertskills")
    public int insertSkills(@RequestBody Skills skills){
        return myService.insertSkills(skills);
    }
    @PostMapping("updateskills")
    public int updateSkillsById(@RequestBody Skills skills){
        return myService.updataSkills(skills);
    }
    @PostMapping("updatasignature")
    public int updataSignature(@RequestBody MyMessage myMessage){
        return myService.updataSignature(myMessage);
    }
    @PostMapping("deleteescription")
    public int deleteEscription(@RequestBody Description description){
        return myService.deleteEscription(description);
    }
    @PostMapping("insertdescription")
    public int insertDescription(@RequestBody Description description){
        return myService.insertDescription(description);
    }
    @PostMapping("updatenotice")
    public int updateNotice(@RequestBody MyMessage myMessage){
        return myService.updateNotice(myMessage);
    }
    @PostMapping("uodateavatar")
    public int uodateAvatar(@RequestBody MyMessage myMessage){
        return myService.uodateAvatar(myMessage);
    }

    @GetMapping("redis")
    public Object findredis(){
        return myService.test();
    }
}
